import java.util.Scanner;

public class NumberConverter {
    public static void main(String[] args) {
        System.out.println("Enter arabic number: ");
        Scanner in = new Scanner(System.in);
        int number = in.nextInt();
        System.out.println("Roman number:");
        System.out.print(arabicToRoman(number));
    }

    static String arabicToRoman(int number) {
        String[] romanLimits = new String[]{"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"};
        int[] numbersLimits = new int[]{1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
        String result = "";
        for (int i = romanLimits.length - 1; i >= 0; i--) {
            while (number >= numbersLimits[i]) {
                result = result + romanLimits[i];
                number = number - numbersLimits[i];
            }
        }
        return result;
    }
}
